class Side:
    _NEITHER = 0
    _LEFT = 1
    _RIGHT = 2
    _BOTH = 3

    _names = { _NEITHER: 'neither',
               _LEFT: 'left',
               _RIGHT: 'right',
               _BOTH: 'both' }

    def __init__(self, side):
        if isinstance(side, int) \
           and (side == self._NEITHER \
                or side == self._LEFT \
                or side == self._RIGHT \
                or side == self._BOTH):
            self._side = side
        elif isinstance(side, str):
            side = side.lower()
            for key, value in self._names.iteritems():
                if side == value:
                    self._side = key

    def __eq__(self, other):
        return self._side == other._side

    def __str__(self):
        return self._names[self._side]

    def includes_left(self):
        return self._side == self._LEFT or self._side == self._BOTH

    def includes_right(self):
        return self._side == self._RIGHT or self._side == self._BOTH
        
    def opposite(self):
        if self._side == self._NEITHER:
            return Side(self._BOTH)
        elif self._side == self._LEFT:
            return Side(self._RIGHT)
        elif self._side == self._RIGHT:
            return Side(self._LEFT)
        elif self._side == self._BOTH:
            return Side(self._NEITHER)

NEITHER = Side(Side._NEITHER)
LEFT = Side(Side._LEFT)
RIGHT = Side(Side._RIGHT)
BOTH = Side(Side._BOTH)
